<%-- 
    Document   : Searchlive_hotenKH
    Created on : Dec 23, 2014, 2:59:07 PM
    Author     : thien_000
--%>
<%@page import="Model.Connect"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%

            Connection con = null;
            PreparedStatement stm = null;
            ResultSet rs = null;
            try {
                con = Connect.GetConnect();
                String q = request.getParameter("q");
                String output = "";
                String result = "";
                String sql = "SELECT HoTen FROM khachhang WHERE HoTen LIKE '%" + q + "%'";
                stm = con.prepareStatement(sql);
                rs = stm.executeQuery();
                while (rs.next()) {
                    String hoten = rs.getString("HoTen");
                    result = "" + hoten + "";
                    output = output + result + ", ";
                }
                rs.close();
                stm.close();
                con.close();
                out.println(output);
            } catch (Exception e) {
                e.printStackTrace();
            }

        %>
    </body>
</html>
